<?php
class LoginAction extends Action {
	public function index() {
		$this->display();
	}

	public function doLogin() {
		$username=trim($_POST['username']);
		$password=trim($_POST['password']);
		$verify=trim($_POST['verifyCode']);
		$user=M('User');
		$result=$user->where(array('username'=>$username,'password'=>$password))->select();
		if(empty($result)){
			$this->ajaxReturn('ER');
		}else{
			import('ORG.Util.Session');
			Session::set('user',$result['0']['username']);
			$this->ajaxReturn('OK');
		}
		
	}

	public function logout(){
		import('ORG.Util.Session');
		Session::set('user',null);
		$this->redirect('Login/index');
		exit;
    }
}
?>